package com.bw.service;

import com.bw.pojo.Course;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;

public interface CourseRepository extends JpaRepository<Course,Integer> {

    @Transactional
    @Modifying
    @Query("update Course c set c.stock = c.stock - :qty where c.id = :id")
    int updateStock(int id, int qty);
}
